#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int maxProduct(vector<int>& nums) {
        int n = nums.size();
        if (n == 1) return nums[0];
        vector<long long> f(n);
        vector<long long> g(n);
        f[0] = g[0] = nums[0];
        long long ret = nums[0];
        for (int i = 1;i < n;i++)
        {
            long long x = nums[i] % INT_MAX, y = nums[i] * f[i - 1] % INT_MAX, z = nums[i] * g[i - 1] % INT_MAX;
            f[i] = max(max(z, y), x);
            g[i] = min(min(z, y), x);
            ret = max(ret, f[i]);
        }
        for (int i = 0;i < n;i++)
        {
            cout << f[i] << " ";
        }
        cout << endl;
        for (int i = 0;i < n;i++)
        {
            cout << g[i] << " ";
        }
        return ret;
    }
};